home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1402 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.3 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: alt.msdos.programmer,comp.lang.c
  4. Subject: Re: Pascal program works but not C program!
  5. Date: Sat, 13 Jan 96 15:11:02 GMT
  6. Organization: none
  7. Message-ID: <821545862snz@genesis.demon.co.uk>
  8. References: <4cdpr2$psi@lugb.latrobe.edu.au> <4cp3vc$8nh@brahms.tfi.be> <4cpqt6$9r8@solutions.solon.com> <4d3scf$4uk@gap.cco.caltech.edu> <4d4742$n50@solutions.solon.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4d4742$n50@solutions.solon.com>
  15.            seebs@solutions.solon.com "Peter Seebach" writes:
  16.  
  17. >In article <4d3scf$4uk@gap.cco.caltech.edu>,
  18. >Gary E. Ansok <ansok@alumnae.caltech.edu> wrote:
  19. >>Implementations are free to accept other declarations of main().  Indeed,
  20. >>the Rationale (not strictly part of the Standard, of course) says (p. 11)
  21. >>"While many implementations support more than two arguments to main, such
  22. >>practice is neither blessed nor forbidden by the Standard; a program that
  23. >>defines main with three arguments is not _strictly conforming_."
  24. >
  25. >>So your program is not erroneous if it expects three arguments to main(),
  26. >>as long as your compiler accepts it.  It just isn't necessarily portable
  27. >>to any other system (or compiler).
  28. >
  29. >Which is to say, it is no longer strictly conforming, which is to say, it's
  30. >not really C anymore.  A merely "conforming" program (one acceptable to
  31. >at least *one* conforming C compiler) could be in FORTRAN; as long as the
  32. >compiler gives at least one warning, it can translate anything it wants.
  33.  
  34. The difference there is that void main() doesn't require a diagnostic
  35. from the compiler. This doesn't really put it on a higher level though.
  36.  
  37. >The key is that the use of a non-standard declaration of main, just like
  38. >the use of strdup(), introduces "undefined behavior".
  39. >
  40. >On at least one implementation I know of, you can use "gets(NULL)" as
  41. >a way to check a line of input without using a variable.  This is
  42. >also conforming code, and is *EXACTLY* as legal as "void main(void)" or
  43. >"int main(argc, argv, envp) char **argv, **envp;".
  44.  
  45. or
  46.  
  47.  i = i++;
  48.  
  49. or
  50.  
  51.  double d;
  52.  scanf("%f", &d);
  53.  
  54. >>Yes, I think programmers should remove unnecessary non-portabilities
  55. >>from their code.  No, I don't think "void main()" should be the instant
  56. >>flame-trigger it seems to be.
  57. >
  58. >I think it makes sense in a *C* newsgroup.  If you write conforming code,
  59. >you are SOL, and you may be making it gratuitously hard for people to help
  60. >you with your problems.  In general, problems with code that is not legit
  61. >ANSI are hardly ever problems having to do with the C language; they are
  62. >often problems with a given compiler or implementation, which means, they
  63. >should be addressed in a newsgroup more related to that implementation.
  64.  
  65. Right. Starting a program with void main() is saying "I give free license
  66. to the compiler to do whatever it likes with the code". Posting code in
  67. comp.lang.c with (gratuitously) no defined meaning according to the C
  68. language definitionjust adds noise to a newsgroup which already has plenty.
  69.  
  70. -- 
  71. -----------------------------------------
  72. Lawrence Kirby | fred@genesis.demon.co.uk
  73. Wilts, England | 70734.126@compuserve.com
  74. -----------------------------------------
  75.